<?php

namespace common\models\c2\entity;

use Yii;

/**
 * This is the model class for table "{{%life_bill}}".
 *
 * @property integer $id
 * @property integer $user_id
 * @property integer $type
 * @property string $label
 * @property string $value
 * @property integer $year
 * @property integer $month
 * @property string $pay_price
 * @property integer $pay_status
 * @property string $pay_at
 * @property string $content
 * @property string $memo
 * @property integer $status
 * @property string $created_at
 * @property string $updated_at
 */
class LifeBill extends \cza\base\models\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%life_bill}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            // [['id'], 'required'],
            [['id', 'user_id', 'year', 'month'], 'integer'],
            [['pay_price'], 'number'],
            [['pay_at', 'created_at', 'updated_at'], 'safe'],
            [['type', 'pay_status'], 'integer', 'max' => 127],
            [['label', 'memo', 'value'], 'string', 'max' => 255],
            [['status'], 'integer', 'max' => 127],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app.c2', 'ID'),
            'user_id' => Yii::t('app.c2', 'User ID'),
            'type' => Yii::t('app.c2', 'Type'),
            'label' => Yii::t('app.c2', 'Label'),
            'year' => Yii::t('app.c2', 'Year'),
            'month' => Yii::t('app.c2', 'Month'),
            'pay_price' => Yii::t('app.c2', 'Pay Price'),
            'pay_status' => Yii::t('app.c2', 'Pay Status'),
            'pay_at' => Yii::t('app.c2', 'Pay At'),
            'content' => Yii::t('app.c2', 'Content'),
            'memo' => Yii::t('app.c2', 'Memo'),
            'status' => Yii::t('app.c2', 'Status'),
            'created_at' => Yii::t('app.c2', 'Created At'),
            'updated_at' => Yii::t('app.c2', 'Updated At'),
        ];
    }

    /**
     * @inheritdoc
     * @return \common\models\c2\query\LifeBillQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new \common\models\c2\query\LifeBillQuery(get_called_class());
    }
    
    /**
    * setup default values
    **/
    public function loadDefaultValues($skipIfSet = true) {
        parent::loadDefaultValues($skipIfSet);
    }

    public function getUser()
    {
        return $this->hasOne(FeUser::className(), ['id' => 'user_id']);
    }

}
